package bch.maven.plugin.guava;

import com.google.common.collect.EnumHashBiMap;
import com.google.common.collect.BiMap;

public class EnumHashBiMapExample {
    enum Role { ADMIN, USER, GUEST }

    public static void main(String[] args) {
        BiMap<Role, String> roleNameMap = EnumHashBiMap.create(Role.class);
        roleNameMap.put(Role.ADMIN, "Administrator");
        roleNameMap.put(Role.USER, "NormalUser");
        roleNameMap.put(Role.GUEST, "Visitor");

        System.out.println("正向查询：" + roleNameMap.get(Role.ADMIN)); // Administrator
        System.out.println("反向查询：" + roleNameMap.inverse().get("Visitor")); // GUEST
    }
}
